using ns0;
using ns4;
using System;
using System.Collections.Generic;
namespace ns9
{
	public sealed class MultiFormatUPCEANReader : OneDReader
	{
		private List<object> list_0;
		public MultiFormatUPCEANReader(Dictionary<object, object> hints)
		{
			List<object> list = null;
			if (hints != null && hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS))
			{
				list = (List<object>)hints.get_Item(DecodeHintType.POSSIBLE_FORMATS);
			}
			this.list_0 = new List<object>(10);
			if (list != null)
			{
				if (list.Contains(BarcodeFormat.EAN_13))
				{
					this.list_0.Add(new EAN13Reader());
				}
				else
				{
					if (list.Contains(BarcodeFormat.UPC_A))
					{
						this.list_0.Add(new UPCAReader());
					}
				}
				if (list.Contains(BarcodeFormat.EAN_8))
				{
					this.list_0.Add(new EAN8Reader());
				}
				if (list.Contains(BarcodeFormat.UPC_E))
				{
					this.list_0.Add(new UPCEReader());
				}
			}
			if (this.list_0.get_Count() == 0)
			{
				this.list_0.Add(new EAN13Reader());
				this.list_0.Add(new EAN8Reader());
				this.list_0.Add(new UPCEReader());
			}
		}
		public override Result decodeRow(int rowNumber, BitArray bitArray_0, Dictionary<object, object> hints)
		{
			int[] startGuardRange = UPCEANReader.smethod_2(bitArray_0);
			int count = this.list_0.get_Count();
			int i = 0;
			while (i < count)
			{
				UPCEANReader uPCEANReader = (UPCEANReader)this.list_0.get_Item(i);
				Result result;
				try
				{
					result = uPCEANReader.decodeRow(rowNumber, bitArray_0, startGuardRange, hints);
					goto IL_4A;
				}
				catch (ReaderException)
				{
				}
				i++;
				continue;
				IL_4A:
				Result result2;
				if (result.BarcodeFormat.Equals(BarcodeFormat.EAN_13) && result.Text.get_Chars(0) == '0')
				{
					result2 = new Result(result.Text.Substring(1), null, result.ResultPoints, BarcodeFormat.UPC_A);
				}
				else
				{
					result2 = result;
				}
				return result2;
			}
			throw ReaderException.Instance;
		}
	}
}
